import {requestInfo} from '@/api/public.js'
import {http} from '@/api/service.js'
export class mainService {
    static findCommoditys(queryParams){
        return requestInfo({
            url:'/mall/good/Commodity/findCommoditysInES',
            data:queryParams,
            auth:false
        })
    }
    static findHotCommoditys(){
        return requestInfo({
            url:'/mall/good/Commodity/findHotCommodity',
            // data:queryParams,
            auth:false
        })
    }
    static findSpecificationStockByCommodityId(commodityId) {
        const query={
            commodityId
        }
        return requestInfo({
            url:'/mall/good/SpecificationStock/findSpecificationStockByCommodityId',
            params:query,
            auth:false
        })
    }

    static findSpecificationsByCommodityId(commodityId) {
        const query={
            commodityId
        }
        return requestInfo({
            url:'/mall/good/Specification/findSpecificationsByCommodityId',
            params:query,
            auth:false
        })
    }

    static findShippingAddressByUserId(userId) {
        const query={
            userId
        }
        return requestInfo({
            url:'/mall/User/ShippingAddress/findShippingAddressByUserId',
            params:query,
            auth:true
        })
    }

    static putOrder(order) {
        return requestInfo({
            url:'/mall/Order/Order/putOrder',
            data:order,
        })
    }
    static pay(orderId){
        const query={
            orderId
        }
        return requestInfo({
            url:'/mall/Order/Order/payOrder',
            params:query,
        })
    }

    static changeAddress(order){
        return requestInfo({
            url:'/mall/Order/Order/changeAddress',
            data:order,
        })
    }
    // 分页查询订单列表
    static findOrders (queryParams) {
        return requestInfo({
            url: '/mall/Order/Order/findOrders',
            method: 'POST',
            data: queryParams
        });
    }
    //根据ID查询指定的订单(包含外键名称)
    static findOrderForEdit (orderId) {
        const query = {
            orderId
        }
        return requestInfo({
            url: '/mall/Order/Order/findOrderForEdit',
            method: 'POST',
            params: query,
        });
    }
    //根据ID查询指定的订单(包含外键名称)
    static findOrderForView (orderId) {
        const query = {
            orderId
        }
        return requestInfo({
            url: '/mall/Order/Order/findOrderForView',
            method: 'POST',
            params: query,
        });
    }
    static setDefaultAddress(shippingAddress) {
        return requestInfo({
            url:'/mall/User/ShippingAddress/setDefaultAddress',
            data:shippingAddress,
            auth:true
        })
    }
    static getDefaultAddress() {
        return requestInfo({
            url:'/mall/User/ShippingAddress/getDefaultAddress',
            auth:true
        })
    }

    static confirmReceipt(orderId) {
        const query={
            orderId
        }
        return requestInfo({
            url:'/mall/Order/Order/confirmReceipt',
            params:query,
        })
    }
}